<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>matches和closest</title>
</head>
<body>
    <div class="hd">
        <div class="hd">
            <ul>
                <li>后盾人</li>
                <li>houdunren.com</li>
                <li name="xia">xiasnn</li>
            </ul>
        </div>
    </div>
    <script>
        // matches 查找具有某个属性标签
        const tags = Array.from(document.querySelectorAll('li')).filter(tag => {
            return tag.matches('[name]');
        });
        console.log(tags);

        // closest 查找符合条件的父级元素
        console.log(document.querySelector('li').closest('.hd'));
    </script>
</body>
</html>